package com.xcity.game.item.effect;

import com.xcity.db.entity.Player;
import com.xcity.game.common.Cause;
import com.xcity.game.item.GameItem;
import com.xcity.game.item.ItemEffect;
import com.xcity.game.item.listener.BagListener;
import com.xcity.game.pet.Pet;

/**
 * 给宠物加精神
 * @author YangLi
 *
 */
public class AddPetSpiritEffect implements ItemEffect {

	@Override
	public boolean effect(Player player, GameItem item, int count, BagListener listener) {
		Pet pet = player.getPets().getWorkingPet();
		if (pet == null) {
			return false;
		}
		int[] params = item.getTemplate().getParams();
		if (params != null && params.length > 0) {
			int val = params[0] * count;
			return pet.addSpirit(val, Cause.USE_ITEM);
		}
		return false;
	}

}
